package com.lyq.utils;

import javax.swing.*;
import java.awt.*;

public class Tools {
    /**
     * 实现窗口居中
     * @param frame 窗口对象
     * @param width 宽度
     * @param height 高度
     */
    public static void setPos(JFrame frame, int width, int height){
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        int x = (int)screenSize.getWidth()/2-width/2;
        int y = (int)screenSize.getHeight()/2-height/2;
        frame.setBounds(x,y,width,height);
    }

    /**
     * 警告弹窗
     * @param message 提示信息
     */
    public static void showMessage(String message){
        JOptionPane.showMessageDialog(null, message,"提示消息",JOptionPane.WARNING_MESSAGE);
    }
}
